//
//  newsPresenter.m
//  Sinology
//
//  Created by mac on 15/3/31.
//  Copyright (c) 2015年 mac. All rights reserved.
//

#import "newsPresenter.h"

@implementation newsPresenter
DEF_STRING(LOADNEWS,@"LoadNews")
DEF_SINGLETON_AUTOLOAD(newsPresenter)
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self observeNotification:UMOnlineConfigDidFinishedNotification];
    }
    return self;
}
- (id)doSomething:(NSString *)something attributes:(NSArray *)attributeBinded{
    if ([something is:self.LOADNEWS]) {
        [self.delegate presenter:self doSome:self.LOADNEWS bean:@[@{@"name":@"xxxx",@"img":@"http://gtms01.alicdn.com/tps/i1/TB1hTTGHpXXXXauXVXXwu0bFXXX.png"},@{@"name":@"xxxx",@"img":@"http://gtms01.alicdn.com/tps/i1/TB1hTTGHpXXXXauXVXXwu0bFXXX.png"},@{@"name":@"xxxx",@"img":@"http://gtms01.alicdn.com/tps/i1/TB1hTTGHpXXXXauXVXXwu0bFXXX.png"}] state:PresenterProcessSucced error:nil];
        [UMExt updateOnlineConfig];
    }
    return nil;
}

ON_NOTIFICATION(__notification){
    if ([__notification.name isEqualToString:UMOnlineConfigDidFinishedNotification]) {
        if (self.delegate) {
            NSString *news = [UMExt getConfigParams:@"news"];
            [self.delegate presenter:self doSome:self.LOADNEWS bean:news state:PresenterProcessSucced error:nil];
        }
    }
}

@end
